package o;

import com.huawei.appgallery.netdiagnosekit.tasks.deviceip.DeviceIPResBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.hwid.core.constants.HwAccountConstants;

public class cna extends cmu implements IServerCallBack {
    private boolean ˊ;
    private String ˎ;
    private String ˏ;
    private boolean ॱ;

    public cna(cmq o_cmq) {
        super(o_cmq, "DeviceIPTask");
    }

    public void run() {
        cvr.ˏ(cnc.APIMETHOD, DeviceIPResBean.class);
        cvt o_cnc = new cnc();
        o_cnc.setTs_(String.valueOf(System.currentTimeMillis()));
        cmx.ˎ().ˏ(o_cnc, this);
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            if (!this.ॱ) {
                cmp.ˊ.ˋ("DeviceIPTask", "query store api interrupted by diagnoser");
            }
        }
        if (!this.ॱ) {
            cmp.ˊ.ˋ("DeviceIPTask", "DeviceIPTask interrupted");
            this.ˎ = "timeout";
            this.ˏ = "connect store server timeout";
            this.ˋ.ˊ(-101, 1, ˊ());
            this.ˋ.ˊ(-105, 1, ˋ());
            this.ॱ = true;
        }
    }

    public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        int i;
        if (responseBean == null) {
            cmp.ˊ.ˋ("DeviceIPTask", "response is null");
            this.ˎ = HwAccountConstants.EXTRA_OPLOG_ERROR;
            this.ˏ = "connect store server failed";
        } else if ((responseBean instanceof DeviceIPResBean) && responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
            this.ˎ = ((DeviceIPResBean) responseBean).ˎ();
            this.ˏ = "connect store server succeed";
            this.ˊ = true;
        } else {
            cmp.ˊ.ˋ("DeviceIPTask", "rtnCode = " + responseBean.getRtnCode_());
            this.ˎ = HwAccountConstants.EXTRA_OPLOG_ERROR;
            this.ˏ = "connect store server failed";
        }
        if (this.ˊ) {
            i = 2;
        } else {
            i = 1;
        }
        if (!this.ॱ) {
            this.ॱ = true;
            this.ˋ.ˊ(-101, i, ˊ());
            this.ˋ.ˊ(-105, i, ˋ());
        }
    }

    public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
    }

    private String ˊ() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Device IP Test\n");
        stringBuilder.append("[deviceIp]:[").append(this.ˎ).append("]\n");
        return stringBuilder.toString();
    }

    private String ˋ() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Business Test\n");
        stringBuilder.append("[business]:[").append(this.ˏ).append("]\n");
        return stringBuilder.toString();
    }
}
